package com.david.dubbo.annotation;

import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;

/**
 * @author David
 * @version V1.0
 * @Package com.david.dubbo.xml
 * @date 2021/4/11 9:40
 */
public class DavidProviderApplication {
    public static void main(String[] args) throws IOException {
        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(ProviderConfiguration.class);
        context.start();
        System.in.read();
    }

    @Configuration
    @EnableDubbo(scanBasePackages = "com.david.dubbo.annotation.service.impl")
    @PropertySource("classpath:/dubbo-provider.properties")
    static class ProviderConfiguration{

        @Bean
        public RegistryConfig registryConfig(){
            RegistryConfig registryConfig=new RegistryConfig();
            registryConfig.setAddress("zookeeper://192.168.219.102:2181?timeout=10000");

            return registryConfig;
        }


    }

}
